module.exports = (app) => {
  const mongoose = app.mongoose;
  const Schema = mongoose.Schema;
  const UserSchema = new Schema(
    {
      nickname: { type: String, required: true },
      password: { type: String, required: true, select: false },
      email: { type: String, required: false },
      // avatar: {type: String, required: false, default: "/user.jpg"},
      avatar: { type: String, required: true },

      // 关注的用户
      following: { type: [{ type: Schema.Types.ObjectId, ref: "User" }] },
      // 喜欢的文章
      likeArticles: { type: [{ type: Schema.Types.ObjectId, ref: "Article" }] },
    },
    { timestamps: true }
  );
  return mongoose.model("User", UserSchema);
};
